<template>
  <!-- eslint-disable -->
  <div id="main-content" class="buy-box">
    <Scroll ref="tabScroll" :scroll-bars="false" scroll-direction="X" class="tab">
      <div slot="body" ref="tabList" class="tab-list">
        <div v-for="(filter, index) in filterList" @click="selectFilter(filter)" :key="index" :class="['tab-item',  filter.status === currentFilterStatus ? 'active' : null]">
          <span>{{filter.name}}</span>
          <span v-if="filter.num > 0" class="badge">{{filter.num}}</span>
        </div>
      </div>
    </Scroll>
    <Scroll class="release-list" :scroll-more="true" v-for="(filter, index) in filterList" :ref="`scroll_${filter.alias}`" v-show="filter.alias === currentFilterStatusAlias" :key="`${index}-${index}`" @infiniteScroll="getOrderList($event)">
      <div  class="release-item" v-for="(item, i) in orderList" :key="i">
        <router-link class="item-tit" tag="div" :to="{path: `/goods/orderDetails/${item.orderId}`}">
          <div class="order-info">
            <span>{{item.createdOrderTime}}</span>
            <p>
              <span class="pink" :class="{gray: (item.status== 2 || item.status == 12), green: item.status == 10}">{{item.status | orderStatusFilter}}</span>
            </p>
          </div>
          <div class="pro-info">
            <div class="pic">
              <img class="picItem" :src="item.thumbnail | ImgFilter" alt="IMG">
            </div>
            <div class="goods-info">
              <div class="title">
                <span>{{item.productName}}</span>
              </div>
              <div class="money">
                <span>￥{{item.price}}</span>
              </div>
            </div>
            <div class="arrow">
              <i class="icon-arrow"></i>
            </div>
            <!-- 免尾款图标 -->
            <div class="tailing" v-if="item.isGuess == 1"></div>
          </div>
        </router-link>
        <!-- <div @click="test">呵呵</div> -->
        <div class="edit" v-if="item.status !== 2 && item.status !== 12 && item.status !== 8 && item.status !== 10 && item.status !== 14">
          <div>
            <p v-if="item.status == 1 || item.status == 4 || item.status == 3 || item.status == 9" :class="[item.status==3 && item.isGuess==0 ? 'time-orange' : 'time-red' ]">
              <CountDown
                :endInfo="item.status == 3 ? '' : '已结束'"
                :intervalId="`${filter.alias}-${i}`"
                :totalSeconds="item.timeDiffent || 1"
                :timeType="item.status == 9 ? 2 : 1"
                @endTime="handleTimeDownEnd(item)"
              >
                <template v-if="item.status == 1 || item.status == 4">
                  <span slot="first">请在</span>
                  <span>内完成支付</span>
                </template>
                <template  v-if="item.status == 3">
                  <span slot="first">预计</span>
                  <span>后公布免尾款结果</span>
                </template>
                <template v-if="item.status == 9">
                  <span slot="first">将在</span>
                  <span>后自动确认收货</span>
                </template>
              </CountDown>
            </p>
            <p v-if="item.status ==11 && +item.examineStatus === 0">平台审核中</p>
            <p v-if="item.status ==11 && +item.examineStatus === 1">审核被驳回</p>
            <p v-if="item.status ==11 && +item.examineStatus === 2">转卖中</p>
          </div>
          <div class="btns">
            <button v-if="+item.status === 11 && +item.examineStatus === 1" @click="resellPop(item)" class="edit-btn">再次申请</button>
            <!-- <button class="edit-btn" v-if="item.status === 11 && item.examineStatus === 2" @click="handleEditPricePop(item)">编辑价格</button> -->
            <button class="edit-btn active" v-if="+item.status === 11 && +item.examineStatus === 2" @click="goOther(1)">查看转卖</button>
            <button
              :class="['edit-btn', item.status !== 11 ? 'active' : null]"
              @click="handleEdit(item)"
            >{{item.status | orderStatusBtnFilter}}</button>
            <button class="edit-btn" v-if="item.status === 1" @click="cancelOrderPop(item)">取消订单</button>
            <button class="edit-btn" v-if="item.status === 7" @click="resellPop(item)">一键转卖</button>
          </div>
        </div>
      </div>
    </Scroll>
    <div class="noList" v-if="emptyList">您暂无买到的商品，快去买一个吧！</div>
    <Popups :isShow.sync="isPopup_resell" title="转卖商品">
      <div slot="body">
        <Scroll ref="scroll_resell" style="height: 5.2rem;">
          <div class="form-item">
            <label class="form-label">商品原价</label>
            <span class="text">{{currentItem.price}}</span>
            <span>元</span>
          </div>
          <div class="form-item">
            <label class="form-label">转卖价格</label>
            <input type="number" v-model.number.trim="sellPrice" value="" class="form-input" placeholder="请输入转卖价格">
            <span>元</span>
          </div>
          <div class="form-item">
            <label class="form-label">最终售价</label>
            <span class="text">{{+sellPrice + +currentItem.postage}}</span>
            <span>元</span>
          </div>
          <div class="tip">
            <span>提示：商品最终售价=转卖价+运费{{currentItem.postage}}</span>
          </div>
          <div class="explain">
            <p class="tip" @click="handleExplain"><span class="icon-explain"></span>转卖说明<span class="icon-arrow"></span></p>
            <div class="text-box" >  <!--v-show="isExplainshow"-->
              <p class="txt">你在设置转卖价格后，此商品将会提交至优众转卖平台(resell.ihaveu.com)进行审核，审核通过后将在转卖首页进行转卖，转卖成功后款项将打至您的集分竞宝APP钱包中。</p>
              <p class="href" @click="goOther(1)">去优众转卖平台</p>
              <p class="href" @click="goOther(2)">下载集分竞宝APP</p>
            </div>
          </div>
        </Scroll>
      </div>
      <button class="edit-sub" @click="resellPro(currentItem)" slot="footer">确定</button>
    </Popups>
    <!-- <Popups :isShow.sync="isPopup_edit" title="编辑价格">
      <div slot="body">
        <div class="form-item">
          <label class="form-label">商品原价</label>
          <span class="text">{{currentItem.price}}</span>
          <span>元</span>
        </div>
        <div class="form-item">
          <label class="form-label">转卖价格</label>
          <input type="number" v-model.number.trim="sellPrice" value="" class="form-input" placeholder="请输入转卖价格">
          <span>元</span>
        </div>
        <div class="form-item">
          <label class="form-label">最终售价</label>
          <span class="text">{{+sellPrice + +currentItem.postage}}</span>
          <span>元</span>
        </div>
        <div class="tip">
          <span>提示：商品最终售价=转卖价+运费</span>
        </div>
        <div class="explain">
          <p class="tip" @click="isExplainshow=!isExplainshow"><span class="icon-explain"></span>转卖说明<span class="icon-arrow"></span></p>
          <div class="text-box" v-show="isExplainshow">
            <p class="txt">你在设置转卖价格后，此商品将会提交至优众转卖平台(resell.ihaveu.com)进行审核，审核通过后将在转卖首页进行转卖，转卖成功后款项将打至您的集分竞宝APP钱包中。</p>
            <p class="href">去优众转卖平台</p>
            <p class="href">下载集分竞宝APP</p>
          </div>
        </div>
      </div>
      <button class="edit-sub" @click="handleEditPrice(currentItem)" slot="footer">确定</button>
    </Popups> -->
    <Popups :isShow.sync="isPopup_resellCancel" title="取消转卖">
      <div  class="cancel-info info-center" slot="body">
        <span>是否取消转卖该商品？</span>
      </div>
      <div slot="footer" class="pop-footer-btns">
        <button class="pop-footer-cancel" @click="closePopAll" >再想想</button>
        <button class="pop-footer-sub" @click="resellCancel">确定</button>
      </div>
    </Popups>
    <Popups :isShow.sync="isPopup_cancelOrder" title="取消订单">
      <div  class="cancel-info info-center" slot="body">
        <span>是否取消该订单？</span>
      </div>
      <div slot="footer" class="pop-footer-btns">
        <button class="pop-footer-cancel" @click="closePopAll" >再想想</button>
        <button class="pop-footer-sub" @click="cancelOrder(currentItem)">确定</button>
      </div>
    </Popups>
    <Popups :isShow.sync="isPopup_sureGet" title="确认收货">
      <div  class="cancel-info info-center" slot="body">
        <span>请确认您已收到商品</span>
      </div>
      <div slot="footer" class="pop-footer-btns">
        <button class="pop-footer-cancel" @click="closePopAll" >再想想</button>
        <button class="pop-footer-sub" @click="sureGet(currentItem)">确定</button>
      </div>
    </Popups>
    <Popups :isShow.sync="isPopup_takeSuccess" title="提货成功">
      <div  class="cancel-info" slot="body">
        <span>提货成功， 我们会尽快为您发货</span>
      </div>
      <div slot="footer" class="pop-footer-btns">
        <button class="pop-footer-sub" >确定</button>
      </div>
    </Popups>
    <Popups :isShow.sync="isPopup_paytail" title="提示">
      <div  class="cancel-info" slot="body">
        <span>您的预测结果未出炉，若预测成功将获得免尾款。您确定放弃免尾款机会？</span>
      </div>
      <div slot="footer" class="pop-footer-btns">
        <button class="pop-footer-cancel" @click="closePopAll" >再想想</button>
        <button @click="handlePayment(currentItem)" class="pop-footer-sub" >确定</button>
      </div>
    </Popups>
    <vFooter ref="vFooter" />
  </div>
</template>
<script>
import { Popups } from "~/popOut/";
import CountDown from "~/countDown";
import { Scroll } from "~/vScroll";
import Ajax from "@/mixins/ajax";
import href from "@/mixins/href";
import vFooter from "~/footer/index.vue";

// 我的订单列表
const orderListUrl = "/card-service-web/onePercent/queryOrder";
// 创建订单
// const createOrders = "/card-service-web/resell/createOrders";
// 取消订单
const setCloseBuyUrl = "/card-service-web/resell/closeBuy";
// 支付宝支付接口
const alipayUrl = "/card-service-web/alipay/aliPayOnePercent";
// 我买到的记录新街口
// const getRecordByCondition = "/card-service-web/resell/getRecordByCondition";
// 转卖接口
const resellUrl = "/card-service-web/resell/updateResellMall";
// 编辑转卖价格
const editPriceUrl = "/card-service-web/resell/updateSellPrice";
// 取消转卖
const resellCancelUrl = "/card-service-web/resell/cancelResell";
// 提货接口
const takeGoodsUrl = "/card-service-web/onePercent/onePayReSell";
// 取消订单
const canCelUrl = "/card-service-web/onePercent/cancelOrder";
// 确认收货
const sureGetUrl = "/card-service-web/onePercent/confirmGoodsOrders";

const successPayment = {
  title: "",
  type: 1,
  info: "购买成功"
};
const filters = [
  {
    name: "全部",
    status: 0,
    alias: "all"
  },
  {
    name: "待付款",
    status: 1,
    num: 0,
    alias: "payment"
  },
  {
    name: "待提货",
    status: 2,
    num: 0,
    alias: "waitForecast"
  },
  {
    name: "待收货",
    status: 3,
    alias: "waitReceived"
  },
  {
    name: "已完成",
    status: 4,
    alias: "completed"
  }
];
export default {
  name: "orderList",
  mixins: [Ajax, href],
  components: {
    Popups,
    CountDown,
    Scroll,
    vFooter
  },
  filters: {
    orderStatusFilter(value) {
      let state = "";
      switch (value) {
        case 1:
          state = "待付定金";
          break;
        case 2:
          state = "已取消";
          break;
        case 3:
          state = "结果公布中";
          break;
        case 4:
          state = "待付尾款";
          break;
        case 7:
          state = "待提货";
          break;
        case 8:
          state = "待发货";
          break;
        case 9:
          state = "待收货";
          break;
        case 10:
          state = "已完成";
          break;
        case 11:
          state = "转卖中";
          break;
        case 12:
          state = "已关闭";
          break;
        case 14:
          state = "转卖成功";
          break;
        default:
          state = "";
          break;
      }
      return state;
    },
    orderStatusBtnFilter(value) {
      let result = "";
      switch (+value) {
        case 1:
          result = "支付定金";
          break;
        case 7:
          result = "立即提货";
          break;
        case 11:
          result = "取消转卖";
          break;
        case 3:
          result = "支付尾款";
          break;
        case 4:
          result = "支付尾款";
          break;
        case 9:
          result = "确认收货";
          break;
        default:
          result = "支付尾款";
          break;
      }
      return result;
    }
  },
  data() {
    return {
      // 转卖pop控制
      isPopup_resell: false,
      // 编辑价格pop控制
      isPopup_edit: false,
      // 是否确认支付尾款
      isPopup_paytail: false,
      // 提货成功pop控制
      isPopup_takeSuccess: false,
      // 取消订单pop
      isPopup_cancelOrder: false,
      // 确认收货pop
      isPopup_sureGet: false,
      // 转卖说明显示隐藏
      isExplainshow: false,
      // 记录当前商品的原价
      originalPrice: 0,
      // 修改价格后的数据
      sellPrice: 0,
      // 邮费
      postage: 0,
      busy: false,
      // 当前选中订单
      currentItem: {},
      // pop窗口状态
      isPopup_resellCancel: false,
      // 我买到的列表
      myBuyList: {},
      // 订单id
      orderId: 0,
      // 是否提交中
      submiting: false,
      // 当前买到的列表
      orderList: [],
      // 当前买家ID
      currentBuyUserId: 0,
      // 当前卖家ID
      currentSellUserId: 0,
      // 当前商品订单ID
      currentOrderId: 0,
      // 转卖ID
      currentMallResellId: 0,
      // 订单ID
      mallSellOrderId: 0,
      // 列表为空？
      emptyList: false,
      isPopup_payment: false,
      // 支付成功提示
      popTip: successPayment,
      // 筛选列表
      filterList: filters,
      // 当前筛选状态
      currentFilterStatus: 0,
      // 当前筛选状态的别名
      currentFilterStatusAlias: "all"
    };
  },
  // 页面进入
  beforeRouteEnter(to, from, next) {
    next(vm => {
      // 更新IScroll尺寸
      vm.$nextTick(() => {
        vm.$refs[`scroll_${vm.currentFilterStatusAlias}`][0].refresh();
      });
    });
  },
  mounted() {
    // 支付成功判断
    const { totalAmout } = this.$route.query;
    if (totalAmout) {
      this.isPopup_payment = true;
    }
    this.getOrderList();
    // 更新IScroll尺寸
    this.$nextTick(() => {
      const tabListHeight =
        parseInt(this.getStyle(this.$refs.tabList, "height"), 10) + 1;
      this.$refs.tabScroll.$el.style.height = `${tabListHeight}px`;
      const tabScrollHeight = parseInt(
        this.getStyle(this.$refs.tabScroll.$el, "height"),
        10
      );
      const footerEl = this.$refs.vFooter.$el;
      const footerElHeight = this.getElHeight(footerEl);
      const mainHeight =
        this.windowHeight -
        (this.headerElHeight + tabScrollHeight + footerElHeight);
      filters.forEach(item => {
        this.$refs[
          `scroll_${item.alias}`
        ][0].$el.style.height = `${mainHeight}px`;
      });

      this.$refs.tabScroll.refresh();
    });
  },
  methods: {
    /**
     * 展开转卖说明
     */
    handleExplain() {
      this.isExplainshow = !this.isExplainshow;
      this.$nextTick(() => {
        this.$refs.scroll_resell.refresh();
      });
    },
    /**
     * 1： 支付定金, 4: 支付尾款, 7: 立即提货, 11: 取消专卖
     */
    handleEdit(item) {
      const statu = +item.status;
      if (statu === 1) {
        this.handlePayment(item);
      } else if (statu === 3) {
        this.isPopup_paytail = !this.isPopup_paytail;
        this.currentItem = item;
      } else if (statu === 4) {
        this.handlePayment(item);
      } else if (statu === 7) {
        this.takeGoods(item);
      } else if (statu === 11) {
        this.resellCancelPop(item);
      } else if (statu === 9) {
        this.sureGetPop(item);
      }
    },
    /**
     * 修改列表状态 废弃
     * @param [Object] currentItem 当前选择订单对象
     */
    setOrderItemStatus(currentItem, changeStatus) {
      /* eslint-disable */
      // 当前筛选数量-1
      this.filterList.forEach((item, index) => {
        if (item.status === currentItem.status) {
          if (item.num && item.num > 0) {
            --this.filterList[index].num;
          }
        }
      });
      this.orderList.forEach((order, index) => {
        if (order.orderId === currentItem.orderId) {
          this.orderList[index].status = changeStatus;
        }
      });
      this.orderList = this.orderList.filter(item => {
        return item.orderId !== currentItem.orderId;
      });
    },
    /**
     * 一键转卖弹框
     */
    resellPop(item) {
      this.sellPrice = item.price;
      this.isExplainshow = false;
      this.currentItem = item;
      this.isPopup_resell = !this.isPopup_resell;
      this.$nextTick(() => {
        this.$refs.scroll_resell.refresh();
      });
    },
    // test(){
    //   this.isExplainshow = false;
    //   this.isPopup_resell = !this.isPopup_resell;
    // },
    /**
     * 一键转卖
     */
    resellPro(currentItem) {
      this.isPopup_resell = !this.isPopup_resell;
      this.post(resellUrl, {
        type: 3,
        id: currentItem.orderId,
        price: parseInt(+this.sellPrice + +currentItem.postage)
      }).then(body => {
        if (+body.execErrCode === 200) {
          this.currentPageNo = 0;
          this.getOrderList();
          const errorObj = {
            isPrompt: true,
            isCloseEl: true,
            isConfirm: true,
            title: "",
            info:
              "您的商品已提交至转卖平台(resell.ihaveu.com)审核，审核通过后将在转卖平台进行售卖",
            isMaskDown: true,
            textAlign: "center"
          };
          this.$emit("onPrompt", errorObj);
          // this.getOrderList();
        }
      });
    },
    /**
     * 取消转卖弹框
     */
    resellCancelPop(item) {
      this.currentItem = item;
      this.orderId = item.orderId;
      this.isPopup_resellCancel = !this.isPopup_resellCancel;
    },
    /**
     * 取消转卖
     */
    resellCancel() {
      this.post(resellCancelUrl, {
        crazyId: this.orderId
      }).then(body => {
        if (+body.execErrCode === 200) {
          this.currentPageNo = 0;
          this.getOrderList();
          this.closePopAll();
        }
      });
    },
    /**
     * 编辑价格弹框
     */
    handleEditPricePop(item) {
      this.isExplainshow = false;
      this.sellPrice = 0;
      this.currentItem = item;
      this.isPopup_edit = !this.isPopup_edit;
    },
    /**
     * 编辑价格
     */
    handleEditPrice(currentItem) {
      /* eslint-disable */
      let { currentOrderId, sellPrice } = this;
      if (sellPrice === "") {
        this.$refs.sellPrice.focus();
        return;
      }
      this.isPopup_edit = !this.isPopup_edit;
      if (!this.submiting) {
        this.post(editPriceUrl, {
          type: 3,
          mallResellId: currentItem.orderId,
          price: parseInt(+this.sellPrice + +currentItem.postage)
        }).then(body => {
          this.isPopup_edit = !this.isPopup_edit;
          this.currentPageNo = 0;
          // 重新加载

          this.submiting = false;
        });
      }
      this.submiting = true;
    },
    /**
     * 立即提货
     */
    takeGoods(item) {
      this.post(takeGoodsUrl, {
        orderId: item.orderId
      }).then(body => {
        if (+body.execErrCode === 200) {
          this.currentPageNo = 0;
          this.getOrderList();
          const errorObj = {
            isPrompt: true,
            isCloseEl: true,
            isConfirm: true,
            title: "提货成功",
            info: "",
            isMaskDown: true,
            textAlign: "center"
          };
          this.$emit("onPrompt", errorObj);
        }
      });
    },
    /**
     * 取消订单弹框
     */
    cancelOrderPop(item) {
      this.currentItem = item;
      this.isPopup_cancelOrder = !this.isPopup_cancelOrder;
    },
    /**
     * 取消订单
     */
    cancelOrder(currentItem) {
      this.post(canCelUrl, {
        orderId: currentItem.orderId
      }).then(body => {
        this.isPopup_cancelOrder = !this.isPopup_cancelOrder;
        if (+body.execErrCode === 200) {
          this.currentPageNo = 0;
          this.getOrderList();
          // const errorObj = {
          //   isPrompt: true,
          //   isCloseEl: true,
          //   isConfirm: false,
          //   title: "订单已取消",
          //   info: body.execMsg,
          //   isMaskDown: true,
          //   textAlign: "center"
          // };
          // this.$emit("onPrompt", errorObj);
        }
      });
    },
    /**
     * 确认收货弹框
     */
    sureGetPop(item) {
      this.currentItem = item;
      this.isPopup_sureGet = !this.isPopup_sureGet;
    },
    /**
     * 确认收货
     */
    sureGet(currentItem) {
      this.isPopup_sureGet = !this.isPopup_sureGet;
      this.post(sureGetUrl, {
        orderId: currentItem.orderId
      }).then(body => {
        if (+body.execErrCode === 200) {
          this.currentPageNo = 0;
          this.getOrderList();
          const errorObj = {
            isPrompt: true,
            isCloseEl: true,
            isConfirm: false,
            title: "确认收货成功",
            info: body.execMsg,
            isMaskDown: true,
            textAlign: "center"
          };
          this.$emit("onPrompt", errorObj);
        }
      });
    },
    /**
     * 刷新当前页
     */
    goMyBuy() {
      this.isPopup_payment = false;
      this.$router.replace({ name: "myBuy" });
    },
    /**
     * 定时器结束
     */
    handleTimeDownEnd(item) {
      this.currentPageNo = 0;
      this.getOrderList();
    },
    /**
     * 关闭所有pop
     */
    closePopAll() {
      this.isPopup_paytail = false;
      this.isExplainshow = false;
      this.isPopup_sureGet = false;
      this.isPopup_cancelOrder = false;
      this.isPopup_resell = false;
      this.isPopup_resellCancel = false;
      this.isPopup_takeSuccess = false;
    },
    /**
     * 获取我的订单列表
     */
    getOrderList(status, reload) {
      if (typeof status === "boolean") {
        reload = status;
        status = this.currentFilterStatus;
      }
      if (reload) {
        this.currentPageNo = 0;
      }
      const url =
        this.currentFilterStatusAlias === "all" ? orderListUrl : orderListUrl;
      ((status, currentFilterStatusAlias) => {
        this.post(url, {
          type: status,
          /* eslint-disable */
          pageNo: ++this.currentPageNo,
          pageSize: 10
        }).then(body => {
          if (body.execDatas.length === 0) {
            // 如果返回列表为空则不需要更新列表
            this.$refs[`scroll_${currentFilterStatusAlias}`][0].setEndMoreText(
              "我已经没有更多了"
            );
            this.currentPageNo <= 1 && (this.orderList = []);
            --this.currentPageNo;
          }

          // 如果为第一页则不需要concat
          if (this.currentPageNo <= 1 && body.execDatas.length !== 0) {
            this.orderList = body.execDatas;
          } else {
            this.orderList = (this.orderList || []).concat(body.execDatas);
          }
          // 设置当前渲染列表
          // 更新徽章数量
          const { totalNoPay, totalGoods, totalReceive } =
            body.execData[0] || {};
          this.filterList.forEach((item, index) => {
            if (item.status === 2) {
              this.filterList[index].num = totalGoods;
            }
            if (item.status === 1) {
              this.filterList[index].num = totalNoPay;
            }
            if (item.status === 3) {
              this.filterList[index].num = totalReceive;
            }
          });

          // 更新IScroll尺寸
          this.$nextTick(() => {
            this.$refs[`scroll_${currentFilterStatusAlias}`][0].refresh();
          });

          if ((this.orderList || []).length === 0) {
            this.emptyList = true;
          } else {
            this.emptyList = false;
          }
        });
      })(status || this.currentFilterStatus, this.currentFilterStatusAlias);
    },
    /**
     * 处理取消购买订单
     * @param {Object} item 商品详情
     */
    handleCancelPayment(item) {
      // 暂存当前选中买家ID
      this.currentBuyUserId = item.buyUserId;
      // 暂存当前选中的卖家ID
      this.currentSellUserId = item.sellUserId;
      // 暂存当前选中的商品订单ID
      this.currentOrderId = item.orderId;
      // 暂存当前选中的商品转卖订单ID
      this.mallSellOrderId = item.mallSellOrderId;

      this.isPopup_cancel = true;
    },
    /**
     * 弹出确认收货弹框
     */
    handleOpenConfirmMoney(item) {
      // 暂存当前选中的商品订单ID
      this.currentOrderId = item.mallSellOrderId;
    },
    /**
     * 处理付款
     * @param {Object} item 商品详情
     */
    handlePayment(item) {
      if (item.delayDate - Date.now() <= 0) {
        this.getOrderList();
        return;
      }
      // 跳转到确认订单页
      // 并且传递卖家ID 和 转卖ID
      // this.$router.push(
      //   `/goods/MakeSureOrder?mallResllId=${item.mallResellId}&sellUserId=${
      //     item.mallSellOrderId
      //   }`
      // );
      // 没有生成订单步骤则不需要弹出等待窗口
      // const loading = {
      //   isPrompt: true,
      //   isCloseEl: false,
      //   isConfirm: false,
      //   title: "",
      //   info: "正在努力跳转到支付宝请稍等",
      //   isMaskDown: false,
      //   textAlign: "center"
      // };
      // // 弹出等待窗口
      // this.$emit("onPrompt", loading);
      const {
        // 转卖订单ID
        orderNum,
        // 商品名称
        productName,
        // 转卖价格
        sellPrice,
        // 定金价格
        onePrice,
        // 尾款
        tailMoney,
        // 订单id
        orderId,
        // 邮费
        postage
      } =
        item || this.currentItem;
      let totalAmout;
      // 1: 支付定金, 4: 支付尾款, 7: 立即提货, 11: 取消专卖
      if (item.status === 1) {
        totalAmout = +onePrice;
      } else if (item.status === 3 || item.status === 4) {
        totalAmout = +tailMoney + +postage;
      }
      const token = this.getToken();
      const href = `${alipayUrl}?body=${orderNum}&outTradeNo=${orderNum}&subject=${orderNum}&totalAmout=${this.point(
        totalAmout
      )}&returnUrl=${encodeURIComponent(
        `http://${
          window.location.host
        }/?newToken=${token}#/Payment?outTradeNo=${orderId}`
      )}`;
      this.openWith(href);
    },
    /**
     * 确定取消订单
     */
    handleEnsureClose() {
      const { currentBuyUserId, mallSellOrderId } = this;
      // 发送取消订单请求
      this.post(setCloseBuyUrl, {
        buyUserId: currentBuyUserId,
        id: mallSellOrderId
      }).then(body => {
        if (+body.execErrCode === 200) {
          this.orderList = this.orderList.filter(item => {
            return item.mallSellOrderId !== mallSellOrderId;
          });
          // 当前筛选数量-1
          this.filterList.forEach((item, index) => {
            if (item.alias === this.currentFilterStatusAlias) {
              --this.filterList[index].num;
            }
          });
        }
        this.isPopup_cancel = false;
      });
    },
    /**
     * 选择筛选对象
     */
    selectFilter(filter) {
      // 初始化当前页码
      this.currentPageNo = 0;
      // 保存当前的条件状态码
      this.currentFilterStatus = filter.status;
      // 保存当前条件别名
      this.currentFilterStatusAlias = filter.alias;
      // 更新IScroll尺寸
      this.$nextTick(() => {
        this.$refs[`scroll_${filter.alias}`][0].refresh();
      });
      this.orderList = [];
      this.getOrderList(filter.status);
    },
    /**
     * 去其他页面
     * 1： 转卖, 2: 下载集分竞宝
     */
    goOther(type) {
      let host = location.host;
      // 生产
      let href = "";
      if (host == "crazysale.zuanliantech.com") {
        if (type == 1) {
          href =
            "http://resell.ihaveu.com/?newToken=" + this.getToken() + "#/home";
        } else {
          href = "https://card-h5.zuanliantech.com/card/#/down";
        }

        // 测试
      } else {
        if (type == 1) {
          href =
            "http://d2.zuanliantech.com/?newToken=" +
            this.getToken() +
            "#/home";
        } else {
          href = "http://test-card.zuanliantech.com/card/#/down";
        }
      }
      this.goHref(href);
    },
    goHref(href) {
      const u = navigator.userAgent;
      if (navigator.userAgent.indexOf("jfjingbao") <= -1) {
        location.href = href;
      } else {
        // Android
        if (u.indexOf("Android") > -1 || u.indexOf("Adr") > -1) {
          window.Android.redirect(href);
          // ios
        } else {
          WebViewJavascriptBridge.openSafari(href);
        }
      }
    }
  }
};
</script>

<style scoped>
.noList {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 2.6rem;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: center;
  padding-top: 3rem;
  color: #888888;
}
.buy-box {
  width: auto;
  background: #fff;
}
.release-list {
  background: #f5f5f4;
}
.tab {
  height: 1.1rem;
}
.tab-list {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  background: #fff;
  font-size: 0.45rem;
  box-shadow: 0rem 0.01rem 0rem 0rem #e1e1e1;
  padding: 0 0.6rem;
  color: #666;
  border-bottom: 0.01rem solid #e1e1e1;
}
.tab-list .tab-item:first-child {
  margin-left: 0;
}
.tab-list .tab-item {
  display: inline-block;
  white-space: nowrap;
  margin-left: 0.6rem;
  padding: 0.26rem 0 0.29rem;
  position: relative;
}
.tab-list .tab-item.active {
  color: #d11463;
  border-bottom: 0.06rem solid #d11463;
}
.tab-list .badge {
  display: inline-block;
  position: absolute;
  top: 0.1rem;
  right: -0.4rem;
  background-color: #d11463;
  font-size: 0.33rem;
  color: #fff;
  min-width: 0.25rem;
  padding: 0.05rem 0.09rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  border-radius: 200px;
}
.release-item {
  background-color: #fff;
  margin-bottom: 0.45rem;
}
.release-item:first-child {
  margin-top: 0.45rem;
}
.release-item .order-info {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0.48rem 0.35rem 0.48rem;
  font-size: 0.36rem;
  border-bottom: 0.01rem solid #eee;
  color: #666;
}
.release-item .pink {
  color: #d11463;
}
.release-item .green {
  color: #318b12;
}
.release-item .gray {
  color: #999999;
}
.release-item .orange {
  color: #fd4100;
}
.release-item .pro-info {
  position: relative;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: row;
  flex-direction: row;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  padding: 0.46rem 0 0.45rem;
}
.release-item .pro-info .tailing {
  position: absolute;
  width: 1.83rem;
  height: 1.8rem;
  background: url("../../assets/img/order-tailing.png") no-repeat center/contain;
  top: 0.46rem;
  right: 1.04rem;
}
.release-item .item-tit {
  font-size: 0.34rem;
}
.release-item .pic {
  width: 1.8rem;
  height: 1.8rem;
  margin-left: 0.48rem;
  background-color: #8e8e8e;
  overflow: hidden;
}
.release-item .pic .picItem {
  width: 1.8rem;
  height: 1.8rem;
}
.goods-info {
  -webkit-flex-grow: 1;
  flex-grow: 1;
  padding: 0 0.2rem;
}
.goods-info .title {
  margin-bottom: 0.33rem;
  font-size: 0.42rem;
  letter-spacing: 0rem;
  color: #000000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 6rem;
}
.goods-info .money {
  font-size: 0.48rem;
  margin-bottom: 0.35rem;
  line-height: 0.48rem;
  letter-spacing: 0rem;
  color: #000000;
}
.goods-info .state {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: row;
  flex-direction: row;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  font-size: 0.36rem;
  line-height: 0.36rem;
  letter-spacing: 0rem;
  color: #d11463;
}
.item-tit .arrow {
  -webkit-align-self: center;
  align-self: center;
  text-align: right;
  margin-right: 0.48rem;
}
.item-tit .arrow .icon-arrow {
  display: inline-block;
  width: 0.24rem;
  height: 0.43rem;
  background: url("../../assets/img/arrow.png") no-repeat;
  background-size: 100%;
}
.edit {
  justify-content: space-between;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: row-reverse;
  /* flex-direction: row-reverse; */
  height: 1.5rem;
  -webkit-align-items: center;
  align-items: center;
  padding: 0 0.48rem;
  border-top: 0.01rem solid #e1e1e1;
  font-size: 0.36rem;
}
.edit .btns {
  display: flex;
  flex-direction: row-reverse;
}
.edit .edit-btn {
  width: 2.19rem;
  height: 0.9rem;
  background-color: #ffffff;
  border: solid 1px #000000;
  border-radius: 0.1rem;
  font-size: 0.42rem;
}
.edit .edit-btn:nth-child(2) {
  margin-right: 0.3rem;
}
.edit .edit-btn.active {
  background: #d11463;
  color: #fff;
  border: none;
}
/* 弹框按钮公共部分 */
.cancel-info {
  margin-top: 0.63rem;
  font-size: 0.42rem;
}
.pop-footer-btns {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: row;
  flex-direction: row;
  -webkit-justify-content: space-around;
  justify-content: space-around;
}
.pop-footer-cancel {
  width: 2.71rem;
  height: 1.08rem;
  background-color: #5062a6;
  border-radius: 2rem;
  color: #fff;
  font-size: 0.54rem;
}
.pop-footer-sub {
  width: 2.71rem;
  height: 1.08rem;
  background-color: #d11463;
  border-radius: 2rem;
  color: #fff;
  font-size: 0.54rem;
}
.cancel-info {
  margin-top: 0.62rem;
  font-size: 0.42rem;
  text-align: left;
}
.info-center {
  text-align: center;
}
.pop-footer-btns .pop-footer-close {
  width: 5.01rem;
  height: 1.08rem;
  background-color: #d11463;
  border-radius: 2rem;
  color: #fff;
  font-size: 0.54rem;
}

.form-item {
  height: 1rem;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: row;
  flex-direction: row;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-align-items: center;
  align-items: center;
  border-bottom: 0.01rem solid #e1e1e1;
  padding-top: 0.2rem;
  font-size: 0.42rem;
}
.form-item .text {
  -webkit-flex-grow: 1;
  flex-grow: 1;
  max-width: 3.7rem;
  overflow-x: auto;
  text-align: right;
  /* margin-right: 0.25rem; */
}
.form-item .form-input {
  padding: 0.2rem 0;
  text-align: right;
  max-width: 3.7rem;
  font-size: 0.42rem;
  background: none;
  border: none;
}
input:focus {
  outline: none;
}
.tip {
  text-align: left;
  margin-top: 0.3rem;
  margin-bottom: 0.31rem;
  font-size: 0.28rem;
  color: #d11463;
}

.edit .edit-btn {
  width: 2.19rem;
  height: 0.9rem;
  background-color: #fff;
  border: solid 1px #000;
  border-radius: 0.1rem;
}
/* .edit .edit-btn:last-child {
  margin-right: 0.6rem;
} */
.edit-sub {
  width: 5.01rem;
  height: 1.08rem;
  background-color: #d11463;
  border-radius: 2rem;
  font-size: 0.54rem;
  color: #fff;
}
.explain {
  text-align: left;
}
.explain .icon-explain {
  position: relative;
  margin-right: 0.1rem;
  top: 0.05rem;
  display: inline-block;
  width: 0.3rem;
  height: 0.3rem;
  background: url("../../assets/img/icon-help.png") no-repeat center/contain;
  text-align: left;
}
.explain .icon-arrow {
  position: relative;
  margin-left: 0.1rem;
  top: -0.05rem;
  display: inline-block;
  width: 0.12rem;
  height: 0.08rem;
  background: url("../../assets/img/icon-arrow-down.png") no-repeat
    center/contain;
  text-align: left;
}
.explain .icon-arrow.active {
  background: url("../../assets/img/icon-arrow-up.png") no-repeat center/contain;
}
.explain .text-box .txt {
  font-size: 0.28rem;
  color: #333;
  line-height: 0.42rem;
  padding-bottom: 0.2rem;
}
.explain .text-box .href {
  color: #d11463;
  font-size: 0.32rem;
  line-height: 0.8rem;
}
.time-red {
  color: #d11463;
}
.time-orange {
  color: #fd4100;
}
</style>

